package com.mxx.common.security;

/**
 * @author: mxx
 * @date: 2022/3/21
 * @time: 10:34
 * @Description: 描述信息
 */
public class CipherModel {
    private Constant.CipherType type;
    private Constant.CipherBlock block;
    private Constant.CipherPadding padding;
    private String model;

    public CipherModel(Constant.CipherType type, Constant.CipherBlock block, Constant.CipherPadding padding) {
        this.type = type;
        this.block = block;
        this.padding = padding;
    }

    public static String generate(Constant.CipherType type, Constant.CipherBlock block, Constant.CipherPadding padding) {
        return String.format("%s/%s/%s", type.name(), block.name(), padding.getVal());
    }

    public CipherModel generate() {
        if (padding == null) {
            this.padding = Constant.CipherPadding.NO_PADDING;
        }
        this.model = generate(type, block, padding);
        return this;
    }

    public String getModel() {
        return model;
    }

    public CipherModel refreshModel(Constant.CipherPadding padding) {
        this.padding = padding;
        return this;
    }

    public Constant.CipherType getType() {
        return type;
    }

    public Constant.CipherBlock getBlock() {
        return block;
    }

    public Constant.CipherPadding getPadding() {
        return padding;
    }


}
